<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<t:wrapper title="Home">
	<jsp:body>
	
		<div id="home-content">
			<spring:message code="content.body.home"/>
		</div>
		
		<div class="box300">
			<c:choose>
				<c:when test="${isLoggedIn}">
					<spring:message code="content.body.welcome" /> <a href="<c:url value="/start_modify_current_user" />" ><c:out value="${user.getFirstName()} ${user.getLastName()}" /></a>
					<form id="logout-form" method="post" action="<c:url value="/deactivate_user"/>">
						<button type="submit">
							<spring:message code="content.body.deactivate_user"/>
						</button>
					</form>
				</c:when>
				<c:otherwise>
					<%-- Show any login error (if any :) --%>
					<c:if test="${!empty error}">
						<p class="error">${error}
					</c:if>
					
					<form id="login-form" method="post" action="<c:url value="/activate_user"/>">
						<label><spring:message code="content.body.activate_user.email"/></label><input type="text" placeholder="email..." name="email"/>
						<label><spring:message code="content.body.activate_user.password"/></label><input type="password" placeholder="password..." name="password"/>
						
						<spring:message code="mail.reset_password.greetings" var="reset_greetings"/>
						<spring:message code="mail.reset_password.content" var="reset_content" />
						<spring:message code="mail.reset_password.footer" var="reset_footer"/>
						<spring:message code="mail.reset_password.subject" var="reset_subject"/>
					
						<input type="hidden" name="subject" 
							value="${reset_subject}"
						/>
						<input type="hidden" name="greetings" 
							value="${reset_greetings}"
						/>
						<input type="hidden" name="content" 
							value="${reset_content}"
						/>
						<input type="hidden" name="footer" 
							value="${reset_footer}"
						/>
						<label></label><button type="submit">
							<spring:message code="content.body.activate_user"/>
						</button>
						<button type="submit" onclick='this.form.action="<c:url value="/reset_password"/>"'>
							<spring:message code="content.body.reset"/>
						</button>
					</form>
				</c:otherwise>
			</c:choose>
		</div>
		
		<div class="box300" style="margin-top: 8px;">
			<c:forEach items="${events}" var="event">
				<h3><spring:message code="${event.title}" arguments="${event.params}"/></h3>
				<p><spring:message code="${event.description}" arguments="${event.params}"/>
				<c:if test="${!empty event.url}">
					<a href="<c:url value="${event.url}"/>">Link</a>
				</c:if>	
			</c:forEach>
		</div>		
	</jsp:body>
</t:wrapper>